package org.shj.book2.chapter11;

public class Log {

	private static final ThreadLocal<ThreadSpecifyLog> tsLogCollection = new ThreadLocal<ThreadSpecifyLog>();
	
	public static void println(String s){
		getTSLog().println(s);
	}
	
	public static void close(){
		getTSLog().close();
	}
	
	private static ThreadSpecifyLog getTSLog(){
		ThreadSpecifyLog tsLog = tsLogCollection.get();
		if(tsLog == null){
			tsLog = new ThreadSpecifyLog(Thread.currentThread().getName() + "-log.txt");
			tsLogCollection.set(tsLog);
		}
		return tsLog;
	}
}
